package controller;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.ThanhVienDao;

public class ThanhVienController extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse res){
		try {
			
			String tenDN = req.getParameter("tenDN");
			String matKhau = req.getParameter("matKhau");
			String vaiTro = req.getParameter("vaiTro");
			String ghiChu = req.getParameter("ghiChu");
			String pageNext = "";
			
			Boolean rs = ThanhVienDao.themThanhvien(tenDN, matKhau, vaiTro, ghiChu);
			if(rs == true){
				pageNext ="homePage.jsp";
			}else{
				pageNext="addUser.jsp";
			}
			
			RequestDispatcher red = req.getRequestDispatcher(pageNext);
			red.forward(req, res);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse res){
		doPost(req, res);
	}
}
